package com.daohang361.imqq.pugin.decoder;

import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.decoder.InterfaceDecoder;
import com.daohang361.imqq.tool.Hex2Bytes;
import com.daohang361.imqq.tool.MyByteReciveArray;

/** 
 * @author naner E-mail:likun3344@163.com 
 * @create time：2011-5-26 下午07:40:11 
 */
public class DecoderCD implements InterfaceDecoder{
	
	public MyByteReciveArray myArray;
	public QQUser sessionQQ;
	public byte[] decryptAll=null;
	@Override
	public void init(MyByteReciveArray myArray, QQUser sessionQQ) {
		this.myArray=myArray;
		this.sessionQQ=sessionQQ;
	}
	@Override
	public QQUser decode() throws Exception {
		System.out.println("I'M Pugin DecoderCD");
		myArray.decryptRemain(sessionQQ.getAttr("SessionKey"));
		System.out.println("Decoder CD:"+Hex2Bytes.bytesToHexString(myArray.extract(0, 0)));
		sessionQQ.setCommand(0);//不回复,即HexEncodeProtocol失效
		sessionQQ.setLogintimes(sessionQQ.getLogintimes()+1);//登陆包前进
		sessionQQ.setPakage(sessionQQ.getPakage()+1);//登陆包自动增长
		
		return sessionQQ;
	}
	
	/**
	 * 暴力打印
	 */
	public void violence()
	{
		//new ViolenceBytes(decryptAll).violence();
	}

	@Override
	public Object invoke(Object... o) {
		// TODO Auto-generated method stub
		return null;
	}

}
